package org.budo.support.lang.util;

/**
 * @author limingwei
 */
public class BooleanUtil {
    public static Boolean toBoolean(Object object) {
        if (null == object) {
            return null;
        }

        return Boolean.valueOf(object.toString());
    }

    public static Boolean isTrue(Object object) {
        return null != object && ((object instanceof Boolean && (Boolean) object) || (object instanceof String && "true".equals(object)));
    }

    public static Boolean isFalse(Object object) {
        return null != object && ((object instanceof Boolean && !(Boolean) object) || (object instanceof String && "false".equals(object)));
    }

    public static Boolean equals(Boolean bool1, Boolean bool2) {
        return (null == bool1 && null == bool2) || (null != bool1 && null != bool2 && bool1.booleanValue() == bool2.booleanValue());
    }
}